

<template>
  <div>
    <van-nav-bar title="添加问题" left-text="返回" left-arrow @click-left="back" />
    <div>
      <van-form>
        <van-cell-group inset>
          <van-field
              v-model="question.name"
              label="问题名称"
              placeholder="请输入问题名称"
              :rules="[{ required: true, message: '请填写问题名称' }]"
          />

          <van-field
              v-model="question.details"
              label="问题详情"
              placeholder="请输入问题详情"
              :rules="[{ required: true, message: '请填写问题详情' }]"
          />
        </van-cell-group>
        <div style="margin: 16px;">
          <van-button round block type="primary" native-type="button" @click="add">
            保存
          </van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import axios from "axios";
import { useRouter } from "vue-router";

const router = useRouter();
const question = ref({});

const back = () => {
  history.back();
};

const add = () => {
  axios.post("question/add", question.value).then((res) => {
    if (res.data.code == 0) {
      // 跳转
      router.push("/question");
    }
  });
};
</script>

<style scoped>

</style>

